-- recent_recharge
-- created by panyl
-- 最近是否充值问题

return {
    fetch = function(id)
        return true;
    end,

    calc_bonus = function(id)
        local args = PinocchioM.query_quetion(id, "bonus_args") or {};

        return { 2, "gem", args["gem"], };
    end,

    check_answer = function(id, index)
        local cond = PinocchioM.query_quetion(id, "condition");

        if type(cond) ~= "number" or cond <= 0 then
            return 1;
        end

        local last_charge_time = ME.user.dbase:query("last_charge_time", 0);
        local interval = TimeM.getServerTime() - last_charge_time;

        if 1 == index and interval <= cond or
            2 == index and interval > cond then
            return 1;
        end

        return 0;
    end,
};
